package top.xuziyi.crawler;

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import top.xuziyi.crawler.util.ApiUtils;

@EntityScan("top.xuziyi.common.pojo")
@SpringBootApplication
@EnableScheduling
public class CrawlerApplication {

    public static void main(String[] args) {
        SpringApplication.run(CrawlerApplication.class, args);
    }

    @Bean
    public ApiUtils createApiUtils() {
        //创建连接池管理器
        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
        //设置最大连接
        cm.setMaxTotal(200);

        //创建数据抓取工具类
        ApiUtils apiUtils = new ApiUtils();
        apiUtils.setCm(cm);

        return apiUtils;
    }
}
